package com.jungle.mogo.config;

import com.anwen.mongo.handlers.MetaObjectHandler;
import com.anwen.mongo.model.AutoFillMetaObject;
import com.jungle.mogo.entity.pojo.BaseEntity;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author 86189
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(AutoFillMetaObject insertAutoFillMetaObject) {
        insertAutoFillMetaObject.fillValue(BaseEntity::getCreateTime, LocalDateTime.now());
    }

    @Override
    public void updateFill(AutoFillMetaObject updateAutoFillMetaObject) {
        updateAutoFillMetaObject.fillValue(BaseEntity::getCreateTime, LocalDateTime.now());
    }
}